﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using Newtonsoft.Json;
using System.Collections.ObjectModel;

namespace ScriptBox
{
    public class AI_ScriptProject : INotifyPropertyChanged
    {
        private string _projectName;
        private string _workDir;
        private ObservableCollection<AI_ButtonGroup> _buttonGroups = new ObservableCollection<AI_ButtonGroup>();

        public string ProjectName
        {
            get => _projectName;
            set { _projectName = value; OnPropertyChanged(nameof(ProjectName)); }
        }

        public string WorkDir
        {
            get => _workDir;
            set { _workDir = value; OnPropertyChanged(nameof(WorkDir)); }
        }

        public ObservableCollection<AI_ButtonGroup> ButtonGroups
        {
            get => _buttonGroups;
            set { _buttonGroups = value; OnPropertyChanged(nameof(ButtonGroups)); }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string name) =>
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }

    public class AI_ButtonGroup : INotifyPropertyChanged
    {
        private string _groupName;
        private ObservableCollection<AI_ScriptButton> _buttons = new ObservableCollection<AI_ScriptButton>();

        public string GroupName
        {
            get => _groupName;
            set { _groupName = value; OnPropertyChanged(nameof(GroupName)); }
        }

        public ObservableCollection<AI_ScriptButton> Buttons
        {
            get => _buttons;
            set { _buttons = value; OnPropertyChanged(nameof(Buttons)); }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string name) =>
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }

    public class AI_ScriptButton : INotifyPropertyChanged
    {
        private string _title;
        private string _imgPath;
        private string _scriptType;
        private string _scriptContent;
        private string _scriptParameter;

        [JsonProperty("title")]
        public string Title
        {
            get => _title;
            set { _title = value; OnPropertyChanged(nameof(Title)); }
        }

        [JsonProperty("imgPath")]
        public string ImgPath
        {
            get => _imgPath;
            set { _imgPath = value; OnPropertyChanged(nameof(ImgPath)); }
        }

        [JsonProperty("scriptType")]
        public string ScriptType
        {
            get => _scriptType;
            set { _scriptType = value; OnPropertyChanged(nameof(ScriptType)); }
        }

        [JsonProperty("scriptContent")]
        public string ScriptContent
        {
            get => _scriptContent;
            set { _scriptContent = value; OnPropertyChanged(nameof(ScriptContent)); }
        }

        [JsonProperty("scriptParameter")]
        public string ScriptParameter
        {
            get => _scriptParameter;
            set { _scriptParameter = value; OnPropertyChanged(nameof(ScriptParameter)); }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string name) =>
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }
}
